package com.exd.flink.sink.business;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.apache.flink.connector.jdbc.JdbcStatementBuilder;

import com.exd.flink.common.StringTool;
import com.exd.flink.domain.ResourcesBean;

public class ResourcesDataSink implements JdbcStatementBuilder<ResourcesBean>{

	private static final long serialVersionUID = 1L;

	@Override
	public void accept(PreparedStatement preparedStatement, ResourcesBean resourcesBean) throws SQLException {
		preparedStatement.setString(1, resourcesBean.getVin());
		preparedStatement.setString(2, resourcesBean.getServiceId());
		preparedStatement.setString(3, resourcesBean.getServiceName());
		preparedStatement.setInt(4, resourcesBean.getVComputeCpu());
		preparedStatement.setInt(5, resourcesBean.getVComputeMem());
		preparedStatement.setInt(6, resourcesBean.getVDataCpu());
		preparedStatement.setInt(7, resourcesBean.getVDataMem());
		preparedStatement.setObject(8, StringTool.LongToDateString(resourcesBean.getSamplingTime()));
		preparedStatement.setObject(9, StringTool.getNowDateString());
	}

}
